{% extends "base.html" %}

{% load i18n %}
{% load humanize %}
{% load btc_formats %}
{% load static %}

{% block title %}
  {% trans "Dashboard" %}
{% endblock title %}

{% block page_header %}
  <h1>Dashboard</h1>
  <h4>{{ user.email }}</h4>
{% endblock page_header %}

{% block content %}

{% if not user.email_verified %}
  <div class="container">
    <div class="row">
      <div class="col-sm-12">
        <div class="nofadeout alert alert-danger">
          Your email address (<b>{{ user.email }}</b>) has not been confirmed,
          email notifications will not be sent.
          {# FIXME: add flow for reverification #}
          <button type="button" class="close" data-dismiss="alert">×</button>
        </div>
      </div>
    </div>
  </div>
{% endif %}

<div class="container">
  <div class="section">
    <div class="row">
      <h3>Forwarding Addresses</h3>
      {% if forwarding_addresses %}
        <table class="table table-striped table-bordered table-condensed">
          <tr>
            <th>Network</th>
            <th>Input Address</th>
            <th>Destination Address</th>
            <th>Archive</th>
          </tr>
          {% for forwarding_address in forwarding_addresses %}
            <tr>
              <td>
                {{ forwarding_address.coin_symbol|coin_symbol_to_display_name }}
              </td>
              <td>
                <a href="{% url 'address_overview' forwarding_address.coin_symbol forwarding_address.initial_address %}">{{ forwarding_address.initial_address }}</a>
              </td>
              <td>
                <a href="{% url 'address_overview' forwarding_address.coin_symbol forwarding_address.destination_address %}">{{ forwarding_address.destination_address }}</a>
              </td>
              <td>
                <a href="{% url 'user_archive_forwarding_address' forwarding_address.id %}">X</a>
              </td>
            </tr>
          {% endfor %}
        </table>
        <p>
          Please note that for very small payments of 100 bits or less, the payment will not forward as the amount to forward is lower than the mining fee.
        </p>
      {% else %}
        <p>
          You have no forwarding addresses.
        </p>
      {% endif %}
      <a href="{% url 'setup_address_forwarding' 'btc' %}" class="btn btn-primary btn-lg">+ Create Forwarding Addresses</a>
      <h3>Email Notifications Subscriptions</h3>
      {% if address_subscriptions %}
        <table class="table table-striped table-bordered table-condensed">
          <tr>
            <th>Network</th>
            <th>Address</th>
            <th>Delete</th>
          </tr>
          {% for address_subscription in address_subscriptions %}
            <tr>
              <td>{{ address_subscription.coin_symbol|coin_symbol_to_display_name }}</td>
              <td>
                <a href="{% url 'address_overview' address_subscription.coin_symbol address_subscription.b58_address %}">{{ address_subscription.b58_address }}</a>
              </td>
              <td>
                <a href="{% url 'user_unsubscribe_address' address_subscription.id %}">X</a>
              </td>
            </tr>
          {% endfor %}
        </table>
      {% else %}
      <p>
        You have no subscriptions.
      </p>
      {% endif %}
      <a href="{% url 'subscribe_address' 'btc' %}" class="btn btn-primary btn-lg">+ Subscribe to Address</a>
    </div>

    <div class="row">
      <hr />
      <p>
        <a href="{% url 'change_password' %}">Change Password</a>
      </p>
    </div>

  </div>
</div>

{% endblock content %}

